package com.ms.service.module.analysisgroup;

import java.math.BigDecimal;

import com.xpec.c4.game.common.Helper;

/**
 * C幣支出資訊
 * @author 16040
 *
 */
public class CoinExpenditureData {

	/**
	 * 累積值
	 */
	private BigDecimal totalValue;
	
	/**
	 * 警示標準
	 */
	private BigDecimal alertValue;
	
	/**
	 * 是否警示過了
	 */
	private boolean isAlertAlready = false;

	
	public CoinExpenditureData(BigDecimal alertValue){
		this.totalValue = new BigDecimal(0);
		this.alertValue = alertValue;
		this.isAlertAlready = false;
	}
	
	/**
	 * 是否要警示了
	 * @return
	 */
	public boolean isAlert(){
		if(!isAlertAlready && Helper.isGreaterEqual(totalValue, alertValue)){
			isAlertAlready = true;
			return true;
		}
		else return false;
	}
	
	/**
	 * 增加支出
	 * @param addValue
	 */
	public void addTotalValue(BigDecimal addValue){
		totalValue = totalValue.add(addValue);
	}
	
	public BigDecimal getTotalValue() {
		return totalValue;
	}

	public void setTotalValue(BigDecimal totalValue) {
		this.totalValue = totalValue;
	}

	public BigDecimal getAlertValue() {
		return alertValue;
	}

	public void setAlertValue(BigDecimal alertValue) {
		this.alertValue = alertValue;
	}

	/**
	 * 只允許在GMTOOL修改時set false
	 * @param isAlertAlready
	 */
	public void setAlertAlready(boolean isAlertAlready) {
		this.isAlertAlready = isAlertAlready;
	}
	
	/**
	 * 歸零
	 */
	public void setToZero(){
		this.totalValue = new BigDecimal(0);
		this.isAlertAlready = false;
	}

}
